/*
 * @lc app=leetcode.cn id=168 lang=javascript
 *
 * [168] Excel表列名称
 */

// @lc code=start
/**
 * @param {number} n
 * @return {string}
 */
var convertToTitle = function(n) {
    let str="ABCDEFGHIJKLMNOPQRSDUVWXYZ"
    let s=""
    let add
    let res=n
    while(res>26){
       add=parseInt(res/26)
       res=res-add*26
      if(res){s=str[res-1]+s}else{
          s=s+"Z"
          --add
      }
       res=add
    }
    return str[res-1]+s
};
convertToTitle(1048)
// @lc code=end

